﻿using MediatR;
using RedDragon.Common.Domain.Manufacture;
using RedDragon.Common.Infrastructure.Interface;
using T.Common.Domain.Common;

namespace RedDragon.RBAC.API.Application.Common.WarehouseW
{
    public class resourcesSearchHandler : IRequestHandler<resourcesSearchCommon, Result>
    {
        public readonly IBaseRepository<Resources> ResourcesRepository;

        public resourcesSearchHandler(IBaseRepository<Resources> resourcesRepository)
        {
            ResourcesRepository = resourcesRepository;
        }

        public async Task<Result> Handle(resourcesSearchCommon request, CancellationToken cancellationToken)
        {
            var result = new Result() { Code = 0, Msg = "资源数据显示" };
            try
            {
                var list = ResourcesRepository.Query().Where(x=>x.WorkCenterCode == request.WorkCenterCode).ToList();
                result.Data = list;
            }
            catch (Exception)
            {

                throw;
            }
            return result;
        }
    }
}
